import java.util.Arrays;
import java.util.Comparator;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-04-12
 * Time: 18:59
 */
class Person {
    int age;
    String name;

    public Person(int age, String name) {
        this.age = age;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }
}
class AgeCompertor implements Comparator<Person> {
    @Override
    public int compare(Person o1, Person o2) {
        return o2.age - o1.age;
    }
}

class NameCompertor implements Comparator<Person> {
    @Override
    public int compare(Person o1, Person o2) {
        return o2.name.compareTo(o1.name);
    }
}
public class demo01 {
    public static void main(String[] args) {
        Person []person1 = new Person[] {
                new Person(10,"abc"),
                new Person(15,"cde"),
                new Person(25,"jkl")
        };
        AgeCompertor age = new AgeCompertor();
        NameCompertor name = new NameCompertor();
        Arrays.sort(person1,name);
        System.out.println(Arrays.toString(person1));
    }
}
